package com.coastline.fruit.common.task;

import com.coastline.fruit.common.utils.CommonUtil;
import org.slf4j.MDC;

/**
 * Task执行抽象类
 *
 * @author Coastline
 * @date 2025/1/10 21:57
 */
public abstract class AbstractTask {
    /**
     * task执行方法
     */
    public void execute(){
        MDC.put("traceid", CommonUtil.generateTraceId());
        try {
            process();
        } finally {
            MDC.remove("traceid");
        }
    }

    /**
     * task具体执行类
     */
    protected abstract void process();
}
